﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using DuckEntities;
using DuckClient.Helpers;
using System.Collections.Generic;

namespace DuckClient.ViewModel
{
    public class RaftPageViewModel: ViewModelBase
    {
        private DuckViewModel duckViewModel;
        private ChildWindow childWindow;

        public RaftPageViewModel(List<RAFT> rafts, DuckViewModel dvm, ChildWindow cw)
        {
            RaftsResult = rafts;
            this.duckViewModel = dvm;
            this.childWindow = cw;
            this.OKButton = new RelayCommand(OkButtonPressed);
            this.CancelButton = new RelayCommand(CancelButtonPressed);
        }

        private List<RAFT> raftsResult;

        public List<RAFT> RaftsResult
        {
            get { return raftsResult; }
            set
            {
                raftsResult = value;
                RaisePropertyChanged("RaftsResult");
            }
        }

        private RAFT selectedRaft;

        public RAFT SelectedRaft
        {
            get { return selectedRaft; }
            set
            {
                selectedRaft = value;
                RaisePropertyChanged("SelectedRaft");
            }
        }

        public RelayCommand OKButton { get; set; }

        public RelayCommand CancelButton { get; set; }

        private void OkButtonPressed()
        {
            duckViewModel.SelectedRaft = this.SelectedRaft;
            this.childWindow.DialogResult = true;
        }

        private void CancelButtonPressed()
        {
            this.childWindow.DialogResult = false;
        }
    }

    
}
